random

This function generates a random number within a specified range.

long random(long min, long max)

Parameters:
min
The smallest number that can be generated.
max
The largest number that can be generated. This must be equal to or greater than min.

Return value:
A random number between min and max on success, or 0 on failure.

Remarks:
If max is less than or equal to min, min will be returned.

The minimum number that can be generated is -999999999, and the maximum is 999999999.

Example:
// Rolling a pair of dice.

void main()
{
int die1=random(1, 6);
int die2=random(1, 6);
int total=die1 + die2;
alert("Rolling dice", "You rolled a " + die1 + " and a " + die2 + ", for a total of " + total + "!");
}